#coding=utf-8

import epics
import tornado
from controller.BaseHandler import BaseHandler
from controller import cagetDouble
from controller import cagetDouble2

class Handler(BaseHandler):

    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
        # 返回内容
        #self.tplAssigns['values'] = []
        #TC_01 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_01:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度01', TC_01,  '°C'])
        #TC_02 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_02:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度02', TC_02,  '°C'])
        #TC_03 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_03:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度03', TC_03,  '°C'])
        #TC_04 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_04:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度04', TC_04,  '°C'])
        #TC_05 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_05:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度05', TC_05,  '°C'])
        #TC_06 = yield self.backend.submit(cagetDouble, 'EXP_TB_MR:TM:TC_06:TMP:ai')
        #self.tplAssigns['values'].append(['慢化器温度06', TC_06,  '°C'])
        # LCS1PT08 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1PT08:PRS:ai')
        # self.tplAssigns['values'].append(['退耦合层进口压力', LCS1PT08, 'Mpa'])
        # LCS1FT05 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1FT05:FLW:ai')
        # self.tplAssigns['values'].append(['退耦合层进口流量', LCS1FT05, 'm³/h'])
        # LCS1PT04 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1PT04:PRS:ai')
        # self.tplAssigns['values'].append(['水慢化器进口压力', LCS1PT04, 'Mpa'])
        # LCS1FT02 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1FT02:FLW:ai')
        # self.tplAssigns['values'].append(['水慢化器进口流量', LCS1FT02, 'm³/h'])
        # LCS1PT05 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1PT05:PRS:ai')
        # self.tplAssigns['values'].append(['预慢化器进口压力', LCS1PT05, 'Mpa'])
        # LCS1FT03 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS1:LCS1FT03:FLW:ai')
        # self.tplAssigns['values'].append(['预慢化器进口流量', LCS1FT03, 'm³/h'])
        # LCS2PT06 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS2:LCS2PT06:PRS:ai')
        # self.tplAssigns['values'].append(['屏蔽段进口压力', LCS2PT06, 'Mpa'])
        # LCS2FT04 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:LCS2:LCS2FT04:FLW:ai')
        # self.tplAssigns['values'].append(['屏蔽段进口流量', LCS2FT04, 'm³/h'])
        # HWSPT07 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:HWS:HWSPT07:PRS:ai')
        # self.tplAssigns['values'].append(['反射体进口压力', HWSPT07, 'Mpa'])
        # HWSFT03 = yield self.backend.submit(cagetDouble, 'EXP_TB_EU:HWS:HWSFT03:FLW:ai')
        # self.tplAssigns['values'].append(['反射体进口流量', HWSFT03, 'm³/h'])

        tmps = [('EXP_TB_MR:TM:TC_01:TMP:ai', '慢化器温度01', '°C'), 
                ('EXP_TB_MR:TM:TC_02:TMP:ai', '慢化器温度02', '°C'), 
                ('EXP_TB_MR:TM:TC_03:TMP:ai', '慢化器温度03', '°C'),
                ('EXP_TB_MR:TM:TC_04:TMP:ai', '慢化器温度04', '°C'), 
                ('EXP_TB_MR:TM:TC_05:TMP:ai', '慢化器温度05', '°C'), 
                ('EXP_TB_MR:TM:TC_06:TMP:ai', '慢化器温度06', '°C'),
                ('EXP_TB_EU:LCS1:LCS1PT08:PRS:ai', '退耦合层进口压力', 'Mpa'),
                ('EXP_TB_EU:LCS1:LCS1FT05:FLW:ai', '退耦合层进口流量', 'm³/h'),
                ('EXP_TB_EU:LCS1:LCS1PT04:PRS:ai', '水慢化器进口压力', 'Mpa'),
                ('EXP_TB_EU:LCS1:LCS1FT02:FLW:ai', '水慢化器进口流量', 'm³/h'),
                ('EXP_TB_EU:LCS1:LCS1PT05:PRS:ai', '预慢化器进口压力', 'Mpa'),
                ('EXP_TB_EU:LCS1:LCS1FT03:FLW:ai', '预慢化器进口流量', 'm³/h'),
                ('EXP_TB_EU:LCS2:LCS2PT06:PRS:ai', '屏蔽段进口压力', 'Mpa'),
                ('EXP_TB_EU:LCS2:LCS2FT04:FLW:ai', '屏蔽段进口流量', 'm³/h'),
                ('EXP_TB_EU:HWS:HWSPT07:PRS:ai', '反射体进口压力', 'Mpa'),
                ('EXP_TB_EU:HWS:HWSFT03:FLW:ai', '反射体进口流量', 'm³/h')]
        self.tplAssigns['values'] = yield [self.backend.submit(cagetDouble2, item) for item in tmps]
        self.render("ezca/reflect.html", **self.tplAssigns)
